package com.atguigu.lease.common.sms;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ClassName: AliyunSmsConfiguration
 * Description:
 *   aliyun的配置类
 * @Author 刘艳丽
 * @Create 2024/9/26 15:50
 * @Version 1.0
 */
@Configuration
public class AliyunSmsConfiguration {

    @Autowired
    private AliyunSMSProperties properties;

    @Bean
    public Client client(){

        try {
            // 配置信息
            Config config = new Config();
            config.setAccessKeyId(properties.getAccessKeyId());
            config.setAccessKeySecret(properties.getAccessKeySecret());
            config.setEndpoint(properties.getEndpoint());
            // 短信客户端API
            Client client = new Client(config);
            return client;

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}
